import axios from 'axios'

export const TenderComapnyService = class TenderComapnyService {
    static tenderComapnyService = null
    requestUrl = 'http://localhost/tenderCompanys'

    static getInstance() {
        if (this.tenderComapnyService == null) {
            this.tenderComapnyService = new TenderComapnyService()
        }
        return this.tenderComapnyService
    }

    /**
     * 保存的方法
     * @param tenderCompany
     */
    register(tenderCompany) {
        return axios.post(this.requestUrl, tenderCompany)
    }

    /**
     * 修改
     * @param tenderCompany
     */
    update(tenderCompany) {
        return axios.put(this.requestUrl, tenderCompany)
    }

    /**
     * 判断是否已经登记过了
     */
    isExist() {
        return axios.get(`${this.requestUrl}/exist`)
    }

    /**
     * 根据id查询
     * @param id
     */
    getById(id) {
        return axios.get(`${this.requestUrl}/${id}`)
    }
}
